package com.jike.task.week02;

import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;

/**
 * @author Administrator
 */

public enum OkHttpClientEnum {

    CLIENT;

    private OkHttpClient clientInstance;

    private Integer connectTimeout_time = 10;
    private Integer writeTimeout_time = 10;
    private Integer readTimeout_time = 30;

    OkHttpClientEnum() {
        clientInstance = new OkHttpClient.Builder()
                .connectTimeout(connectTimeout_time, TimeUnit.SECONDS)
                .writeTimeout(writeTimeout_time, TimeUnit.SECONDS)
                .readTimeout(readTimeout_time, TimeUnit.SECONDS)
                .retryOnConnectionFailure(true)
                .hostnameVerifier((s, sslSession) -> true)
                .build();
    }

    public OkHttpClient getClientInstance() {
        return clientInstance;
    }
}
